{{Extend "layout"}}
{{Block "title"}}《{{Stored.product.Name}}》{{"版本管理"|T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li><a href="__BACKEND__/official/pay/product_index">{{"产品管理"|T}}</a></li>
<li><a href="__FRONTEND__/product/detail/{{Stored.product.Ident}}" target="_blank">{{Stored.product.Name}}</a></li>
<li class="active">{{"版本管理"|T}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
	<div class="col-md-12">
		<div class="block-flat">
			<div class="header">
				<a href="__BACKEND__/official/pay/product_version_add?productId={{Stored.productID}}" class="btn btn-success pull-right">
					<i class="fa fa-plus"></i>
					{{"添加版本"|T}}
				</a>
				<h3>{{"版本列表"|T}}</h3>
			</div>
			<div class="content">
				<div class="table-responsive">
				<table class="table no-border hover">
					<thead class="no-border">
						<tr>
							<th style="width:60px"><strong>ID</strong></th>
							<th><strong>{{"版本号"|T}}</strong></th>
							<th><strong>{{"类型"|T}}</strong></th>
							<th style="width:70px"><strong>{{"启用"|T}}</strong></th>
							<th style="width:70px"><strong>{{"审核"|T}}</strong></th>
							<th style="width:70px"><strong>{{"升级"|T}}</strong></th>
							<th style="width:170px"><strong>{{"时间"|T}}</strong></th>
							<th style="width:100px" class="text-center"><strong>{{"操作"|T}}</strong></th>
						</tr>
					</thead>
					<tbody class="no-border-y">
                        {{range $k,$v := Stored.listData}}
						<tr>
							<td>{{$v.Id}}</td>
							<td>{{$v.Version}}</td>
							<td>{{$v.Type}}</td>
							<td>
								<div class="checkbox checkbox-success no-margin-y">
									<input id="checkbox-disabled-{{$k}}" class="styled switch-disabled" type="checkbox" data-id="{{$v.Id}}" data-disabled="{{$v.Disabled}}"{{if eq $v.Disabled "N"}} checked="checked"{{end}} value="N" /><label for="checkbox-disabled-{{$k}}">{{"启用"|T}}</label>
								</div>
							</td>
							<td>
								<div class="checkbox checkbox-success no-margin-y">
									<input id="checkbox-audited-{{$k}}" class="styled switch-audited" type="checkbox" data-id="{{$v.Id}}" data-audited="{{$v.Audited}}"{{if eq $v.Audited "Y"}} checked="checked"{{end}} value="Y" /><label for="checkbox-audited-{{$k}}">{{"已审"|T}}</label>
								</div>
							</td>
							<td>
								<div class="checkbox checkbox-success no-margin-y">
									<input id="checkbox-forceUpgrade-{{$k}}" class="styled switch-forceUpgrade" type="checkbox" data-id="{{$v.Id}}" data-forceUpgrade="{{$v.ForceUpgrade}}"{{if eq $v.ForceUpgrade "Y"}} checked="checked"{{end}} value="Y" /><label for="checkbox-forceUpgrade-{{$k}}">{{"强制"|T}}</label>
								</div>
							</td>
							<td>{{"创建"|T}}: {{(Date $v.Created).Format "2006-01-02 15:04:05"}}{{if gt $v.Updated 0}}<br />{{"修改"|T}}: {{(Date $v.Updated).Format "2006-01-02 15:04:05"}}{{end}}</td>
							<td class="text-center">
							<a class="label label-default" href="__BACKEND__/official/pay/product_version_add?productId={{Stored.productID}}&copyId={{$v.Id}}" title="{{"复制"|T}}" data-toggle="tooltip"><i class="fa fa-copy"></i></a>
							<a class="label label-success" href="__BACKEND__/official/pay/product_version_edit?productId={{Stored.productID}}&id={{$v.Id}}" title="{{"编辑"|T}}" data-toggle="tooltip"><i class="fa fa-pencil"></i></a> 
							<a class="label label-danger" href="__BACKEND__/official/pay/product_version_delete?productId={{Stored.productID}}&id={{$v.Id}}" onclick="return confirm('{{"真的要删除吗？"|T}}');" title="{{"删除"|T}}" data-toggle="tooltip"><i class="fa fa-times"></i></a>
							</td>
						</tr>
                        {{end}}
					</tbody>
				</table>		
				</div>
				{{Stored.pagination.Render}}
			</div>
		</div>				
	</div>
</div>
{{/Block}}
{{Block "footer"}}
<script>
$(function(){
	$('input.switch-disabled').on('click',function(r){
		var that=$(this),disabled=that.data('disabled')=='N'?'Y':'N';
		$.get(BACKEND_URL+'/official/pay/product_version_edit',{
			productId:'{{Stored.productID}}',
			disabled:disabled,
			id:that.data('id')
		},function(r){
			if(r.Code==1){
				that.data('disabled',disabled);
				that.prop('checked',disabled=='N');
			}
			App.message({title:'{{"系统消息"|T}}',text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
		},'json');
	});
	$('input.switch-audited').on('click',function(r){
		var that=$(this),audited=that.data('audited')=='N'?'Y':'N';
		$.get(BACKEND_URL+'/official/pay/product_version_edit',{
			productId:'{{Stored.productID}}',
			audited:audited,
			id:that.data('id')
		},function(r){
			if(r.Code==1){
				that.data('audited',audited);
				that.prop('checked',audited=='Y');
			}
			App.message({title:'{{"系统消息"|T}}',text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
		},'json');
	});
	$('input.switch-forceUpgrade').on('click',function(r){
		var that=$(this),forceUpgrade=that.data('forceUpgrade')=='N'?'Y':'N';
		$.get(BACKEND_URL+'/official/pay/product_version_edit',{
			productId:'{{Stored.productID}}',
			forceUpgrade:forceUpgrade,
			id:that.data('id')
		},function(r){
			if(r.Code==1){
				that.data('forceUpgrade',forceUpgrade);
				that.prop('checked',forceUpgrade=='Y');
			}
			App.message({title:'{{"系统消息"|T}}',text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
		},'json');
	});
});
</script>
{{/Block}}